<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网站后台管理系统HTML模板--模板之家 www.cssmoban.com</title>
<link href="/static/css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="/static/bootstrap.min.css" />
<script type="text/javascript" src="/static/js/jquery.js"></script>

<script type="text/javascript">
$(document).ready(function(){
  $(".click").click(function(){
  $(".tip").fadeIn(200);
  });
  
  $(".tiptop a").click(function(){
  $(".tip").fadeOut(200);
});

  $(".sure").click(function(){
  $(".tip").fadeOut(100);
});

  $(".cancel").click(function(){
  $(".tip").fadeOut(100);
});

});
</script>


</head>


<body id="fenye">

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">数据表</a></li>
    <li><a href="#">基本内容</a></li>
    </ul>
    </div>
    
    <div class="rightinfo">
    
    <div class="tools">
    
    	<ul class="toolbar">
        <li class="click"><span><img src="/static/images/t01.png" /></span>添加</li>
        <li class="click"><span><img src="/static/images/t02.png" /></span>修改</li>
        <li><span><img src="/static/images/t03.png" /></span>删除</li>
        <li><span><img src="/static/images/t04.png" /></span>统计</li>
        
        </ul>
        
        
        <ul class="toolbar1">
        <li><span><img src="/static/images/t05.png" /></span>设置</li>
        </ul>
    
    </div>
    <td><input type="text"  placeholder="请输入搜索的标题"/></td>
        <td><input type="submit"  value="搜索" /></td>
    
    <table class="tablelist">
    	<thead>
    	<tr>
        <th><input name="" type="checkbox" value="" /></th>
        <th>编号<i class="sort"><img src="/static/images/px.gif" /></i></th>
        <th>标题</th>
        <th>关键字</th>
        <th>引入地址</th>
        <th>是否审核</th>
        <th>文章内容</th>
        <th>添加时间</th>
        <th>操作</th>
        </tr>
     {foreach name="res" item="vo"}
        </thead>
        <tbody>
        <tr>
            <td><input  type="checkbox"   name="check" value="{$vo.id}"/></td>
            <td>{$vo.id}</td>
            <td>{$vo.title}</td>
            <td>{$vo.keyword}</td>
            <td>{$vo.url}</td>
            <td>
          <?php
            if ($vo['is']=="已审核") {
                echo "<font color='green'>已审核</font>";
             } else{
                echo "<font color='red'>未审核</font>";
             }
            ?>
            </td>
            <td>{$vo.content}</td>
            <td>{$vo.time|date="Y-m-d H:i:s",###}</td>
            <td><a href="#">查看</a>|<a href="javascript:void(0)" class="dell" id="{$vo.id}">删除</a></td>
        </tr>
        </tbody>
   {/foreach}
    </table>



<input type="button" value="全选" id="all">
<input type="button" value="全不选" id="cancel">
<input type="button" value="反选" id="fan">
<button class="del">批量删除</button>


    <center>
        <div id="page" >
            {$res->render()}
        </div>
    </center>  
   
    <div class="pagin">
    	<!-- <div class="message">共<i class="blue">1256</i>条记录，当前显示第&nbsp;<i class="blue">2&nbsp;</i>页</div>
        <ul class="paginList"> -->
        <!-- <li class="paginItem"><a href="javascript:;"><span class="pagepre"></span></a></li>
        <li class="paginItem"><a href="javascript:;">1</a></li>
        <li class="paginItem current"><a href="javascript:;">2</a></li>
        <li class="paginItem"><a href="javascript:;">3</a></li>
        <li class="paginItem"><a href="javascript:;">4</a></li>
        <li class="paginItem"><a href="javascript:;">5</a></li>
        <li class="paginItem more"><a href="javascript:;">...</a></li>
        <li class="paginItem"><a href="javascript:;">10</a></li>
        <li class="paginItem"><a href="javascript:;"><span class="pagenxt"></span></a></li> -->
        <!-- </ul> -->
   
    </div>

    
    
    <div class="tip">
    	<div class="tiptop"><span>提示信息</span><a></a></div>
        
      <div class="tipinfo">
        <span><img src="/static/images/ticon.png" /></span>
        <div class="tipright">
        <p>是否确认对信息的修改 ？</p>
        <cite>如果是请点击确定按钮 ，否则请点取消。</cite>
        </div>
        </div>
        
        <div class="tipbtn">
        <input name="" type="button"  class="sure" value="确定" />&nbsp;
        <input name="" type="button"  class="cancel" value="取消" />
        </div>
    
    </div>
    
    
    
    
    </div>
    
    <script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
	</script>
</body>
</html>
<script src="/static/jq.js"></script>
<script>
    ////单删
    $(document).on('click','.dell',function(){
        var obj = $(this);
        var id = obj.attr('id');
        $.ajax({
            url:'{:url('Zhu/ajaxDel')}',
            data:{id:id},
            type:'get',
            datatype:'json',
            success:function(e){
                if (e==1) {
                    obj.parents('tr').remove();
                    alert('删除成功');
                }
        }
            
            
        })
    })

    //分页
    $(document).on('click','#page a',function (event) {
        event.preventDefault();
        var url=$(this).attr("href");
        $.ajax({
            url:url,
            method:"post"


        }).done(function (res) {
            $("#fenye").html(res);
        })
    })


$(document).ready(function () {
        //全选
        $("#all").click(function(){
            $(":checkbox").prop("checked",true);
        });
        //全不选
        $("#cancel").click(function(){
            $(":checkbox").prop("checked",false);
        });
        //反选
        $(document).on("click", "#fan", function(){
            var box = $("[type='checkbox']");
            box.prop("checked",function (i,val){
                return !val;
            });
        });
    });


//批删
//给删除按钮一个点击事件
    $(".del").click(function(){
        var check = document.getElementsByName('check');
        //定义一个空的数组
        var arr = [];
        //定位一下选中的多选框
        for (var i = 0; i < check.length; i++) {
            if(check[i].checked == true){
                arr.push(check[i].value);
            }
        }

        var ids = arr.toString();
        console.log(ids);
        //发起请求
        $.get("{:url('zhu/delAll')}?id="+ids,function(data){
            if(data==1){
                //成功
                for(var j=0;j<arr.length;j++){
                    $("#"+arr[j]).remove();
                }
               alert('删除成功');
                return true;
            }else{
                //失败
                alert('删除失败');
                return false;
            }
        });
    });
</script>
